package com.lvshi0797.cms.dto;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringUtils;

import com.lvshi0797.cms.entities.FProjectInfo;

public class ProjectDto {
	public static final String P_CHANYE = "产业扶贫";
	public static final String P_ANJU = "安居扶贫";
	public static final String P_JIANKANG = "健康扶贫";
	public static final String P_JIUYE = "就业扶贫";
	public static final String P_JIAOYU = "教育扶贫";
	public static final String P_DOUDI = "兜底保障扶贫";
	public static final String P_SHEHUI = "社会扶贫";
	public static final String P_JINRONG = "金融扶贫";
	public static final String P_QITA = "其他扶贫";

	private String chanyeItem1;
	private String chanyeItem2;
	private String anjuItem1;
	private String anjuItem2;
	private String jiankangItem1;
	private String jiankangItem2;
	private String jiuyeItem1;
	private String jiuyeItem2;
	private String jiaoyuItem1;
	private String jiaoyuItem2;
	private String doudiItem1;
	private String doudiItem2;
	private String shehuiItem1;
	private String shehuiItem2;
	private String jinrongItem1;
	private String jinrongItem2;
	private String jinrongItem3;
	private String qitaItem1;
	private String qitaItem2;
	private String baseId;

	private List<FProjectInfo> projects = new ArrayList<FProjectInfo>();

	public List<FProjectInfo> getProjects() {
		if (StringUtils.isNotEmpty(chanyeItem1)
				&& StringUtils.isNotEmpty(chanyeItem2)) {
			FProjectInfo chanye = new FProjectInfo();
			chanye.setAddYear(this.niandu);
			chanye.setItem(this.chanyeItem1);
			chanye.setMoney(Double.parseDouble(chanyeItem2));
			chanye.setPeojectName(P_CHANYE);
			projects.add(chanye);
		}
		if (StringUtils.isNotEmpty(anjuItem1)
				&& StringUtils.isNotEmpty(anjuItem2)) {
			FProjectInfo anju = new FProjectInfo();
			anju.setAddYear(this.niandu);
			anju.setItem(this.anjuItem1);
			anju.setMoney(Double.parseDouble(anjuItem2));
			anju.setPeojectName(P_ANJU);
			projects.add(anju);
		}
		if (StringUtils.isNotEmpty(jiankangItem1)
				&& StringUtils.isNotEmpty(jiankangItem2)) {
			FProjectInfo jiankang = new FProjectInfo();
			jiankang.setAddYear(this.niandu);
			jiankang.setItem(this.jiankangItem1);
			jiankang.setMoney(Double.parseDouble(jiankangItem2));
			jiankang.setPeojectName(P_JIANKANG);
			projects.add(jiankang);
		}
		if (StringUtils.isNotEmpty(jiuyeItem1)
				&& StringUtils.isNotEmpty(jiuyeItem2)) {
			FProjectInfo jiuye = new FProjectInfo();
			jiuye.setAddYear(this.niandu);
			jiuye.setItem(this.jiuyeItem1);
			jiuye.setMoney(Double.parseDouble(jiuyeItem2));
			jiuye.setPeojectName(P_JIUYE);
			projects.add(jiuye);
		}
		if (StringUtils.isNotEmpty(jiaoyuItem1)
				&& StringUtils.isNotEmpty(jiaoyuItem2)) {
			FProjectInfo jiaoyu = new FProjectInfo();
			jiaoyu.setAddYear(this.niandu);
			jiaoyu.setItem(this.jiaoyuItem1);
			jiaoyu.setMoney(Double.parseDouble(jiaoyuItem2));
			jiaoyu.setPeojectName(P_JIAOYU);
			projects.add(jiaoyu);
		}
		if (StringUtils.isNotEmpty(doudiItem1)
				&& StringUtils.isNotEmpty(doudiItem2)) {
			FProjectInfo doudi = new FProjectInfo();
			doudi.setAddYear(this.niandu);
			doudi.setItem(this.doudiItem1);
			doudi.setMoney(Double.parseDouble(doudiItem2));
			doudi.setPeojectName(P_DOUDI);
			projects.add(doudi);
		}
		if (StringUtils.isNotEmpty(shehuiItem1)
				&& StringUtils.isNotEmpty(shehuiItem2)) {
			FProjectInfo shehui = new FProjectInfo();
			shehui.setAddYear(this.niandu);
			shehui.setItem(this.shehuiItem1);
			shehui.setMoney(Double.parseDouble(shehuiItem2));
			shehui.setPeojectName(P_SHEHUI);
			projects.add(shehui);
		}
		if (StringUtils.isNotEmpty(jinrongItem1)
				&& StringUtils.isNotEmpty(jinrongItem2)) {
			FProjectInfo jinrong = new FProjectInfo();
			jinrong.setAddYear(this.niandu);
			jinrong.setItem(this.jinrongItem1);
			jinrong.setMoney(Double.parseDouble(jinrongItem2));
			jinrong.setDebtMoney(Double.parseDouble(jinrongItem3));
			jinrong.setPeojectName(P_JINRONG);
			projects.add(jinrong);
		}
		if (StringUtils.isNotEmpty(qitaItem1)
				&& StringUtils.isNotEmpty(qitaItem2)) {
			FProjectInfo qita = new FProjectInfo();
			qita.setAddYear(this.niandu);
			qita.setItem(this.qitaItem1);
			qita.setMoney(Double.parseDouble(qitaItem2));
			qita.setPeojectName(P_QITA);
			projects.add(qita);
		}
		return projects;
	}

	public void setProjects(List<FProjectInfo> projectlist) {
		if (projectlist != null) {
			for (Object project2 : projectlist) {
				//[10, 20151, 0.02, 享受3, 2165565.04, 产业扶贫5, 206]
				Object[] obj = (Object[]) project2;
				FProjectInfo project = new FProjectInfo();
				if(obj!=null&&obj.length==7){
					project = new FProjectInfo((int)obj[0], (String)obj[5], (String)obj[3], (Double)obj[4], (Double)obj[2], (String)obj[1]);
				}
				this.niandu = project.getAddYear();
				String peojectName = project.getPeojectName();
				if (P_CHANYE.equals(peojectName)) {
					this.chanyeItem1 = project.getItem();
					this.chanyeItem2 = project.getMoney() + "";
				}
				if (P_ANJU.equals(peojectName)) {
					this.anjuItem1 = project.getItem();
					this.anjuItem2 = project.getMoney() + "";
				}
				if (P_JIANKANG.equals(peojectName)) {
					this.jiankangItem1 = project.getItem();
					this.jiankangItem2 = project.getMoney() + "";
				}
				if (P_JIUYE.equals(peojectName)) {
					this.jiuyeItem1 = project.getItem();
					this.jiuyeItem2 = project.getMoney() + "";
				}
				if (P_JIAOYU.equals(peojectName)) {
					this.jiaoyuItem1 = project.getItem();
					this.jiaoyuItem2 = project.getMoney() + "";
				}
				if (P_DOUDI.equals(peojectName)) {
					this.doudiItem1 = project.getItem();
					this.doudiItem2 = project.getMoney() + "";
				}
				if (P_CHANYE.equals(peojectName)) {
					this.chanyeItem1 = project.getItem();
					this.chanyeItem2 = project.getMoney() + "";
				}
				if (P_SHEHUI.equals(peojectName)) {
					this.shehuiItem1 = project.getItem();
					this.shehuiItem2 = project.getMoney() + "";
				}
				if (P_JINRONG.equals(peojectName)) {
					this.jinrongItem1 = project.getItem();
					this.jinrongItem2 = project.getMoney() + "";
					this.jinrongItem3 = project.getDebtMoney() + "";
				}
				if (P_QITA.equals(peojectName)) {
					this.qitaItem1 = project.getItem();
					this.qitaItem2 = project.getMoney() + "";
				}
				this.projects = projectlist;
			}
		}
	}

	/**
	 * 2015年，但是传参的时候只传2015
	 */
	private String niandu;

	public String getChanyeItem1() {
		return chanyeItem1;
	}

	public void setChanyeItem1(String chanyeItem1) {
		this.chanyeItem1 = chanyeItem1;
	}

	public String getChanyeItem2() {
		return chanyeItem2;
	}

	public void setChanyeItem2(String chanyeItem2) {
		this.chanyeItem2 = chanyeItem2;
	}

	public String getAnjuItem1() {
		return anjuItem1;
	}

	public void setAnjuItem1(String anjuItem1) {
		this.anjuItem1 = anjuItem1;
	}

	public String getAnjuItem2() {
		return anjuItem2;
	}

	public void setAnjuItem2(String anjuItem2) {
		this.anjuItem2 = anjuItem2;
	}

	public String getJiankangItem1() {
		return jiankangItem1;
	}

	public void setJiankangItem1(String jiankangItem1) {
		this.jiankangItem1 = jiankangItem1;
	}

	public String getJiankangItem2() {
		return jiankangItem2;
	}

	public void setJiankangItem2(String jiankangItem2) {
		this.jiankangItem2 = jiankangItem2;
	}

	public String getJiuyeItem1() {
		return jiuyeItem1;
	}

	public void setJiuyeItem1(String jiuyeItem1) {
		this.jiuyeItem1 = jiuyeItem1;
	}

	public String getJiuyeItem2() {
		return jiuyeItem2;
	}

	public void setJiuyeItem2(String jiuyeItem2) {
		this.jiuyeItem2 = jiuyeItem2;
	}

	public String getJiaoyuItem1() {
		return jiaoyuItem1;
	}

	public void setJiaoyuItem1(String jiaoyuItem1) {
		this.jiaoyuItem1 = jiaoyuItem1;
	}

	public String getJiaoyuItem2() {
		return jiaoyuItem2;
	}

	public void setJiaoyuItem2(String jiaoyuItem2) {
		this.jiaoyuItem2 = jiaoyuItem2;
	}

	public String getDoudiItem1() {
		return doudiItem1;
	}

	public void setDoudiItem1(String doudiItem1) {
		this.doudiItem1 = doudiItem1;
	}

	public String getDoudiItem2() {
		return doudiItem2;
	}

	public void setDoudiItem2(String doudiItem2) {
		this.doudiItem2 = doudiItem2;
	}

	public String getShehuiItem1() {
		return shehuiItem1;
	}

	public void setShehuiItem1(String shehuiItem1) {
		this.shehuiItem1 = shehuiItem1;
	}

	public String getShehuiItem2() {
		return shehuiItem2;
	}

	public void setShehuiItem2(String shehuiItem2) {
		this.shehuiItem2 = shehuiItem2;
	}

	public String getJinrongItem1() {
		return jinrongItem1;
	}

	public void setJinrongItem1(String jinrongItem1) {
		this.jinrongItem1 = jinrongItem1;
	}

	public String getJinrongItem2() {
		return jinrongItem2;
	}

	public void setJinrongItem2(String jinrongItem2) {
		this.jinrongItem2 = jinrongItem2;
	}

	public String getJinrongItem3() {
		return jinrongItem3;
	}

	public void setJinrongItem3(String jinrongItem3) {
		this.jinrongItem3 = jinrongItem3;
	}

	public String getQitaItem1() {
		return qitaItem1;
	}

	public void setQitaItem1(String qitaItem1) {
		this.qitaItem1 = qitaItem1;
	}

	public String getQitaItem2() {
		return qitaItem2;
	}

	public void setQitaItem2(String qitaItem2) {
		this.qitaItem2 = qitaItem2;
	}

	public String getNiandu() {
		return niandu;
	}

	public void setNiandu(String niandu) {
		this.niandu = niandu;
	}

	public String getBaseId() {
		return baseId;
	}

	public void setBaseId(String baseId) {
		this.baseId = baseId;
	}

}
